
package pe.com.bn.sach.mantenimiento.controller;

import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import pe.com.bn.sach.mantenimiento.form.ComentarioForm;
import pe.com.bn.sach.service.MantenimientoService;
 
/**
 * @author ce_dpcreditos07
 *
 * TODO Para cambiar la plantilla de este comentario generado, vaya a
 */
public class ComentarioController extends MultiActionController {
	
    private String listar;
    
    
    private MantenimientoService mantenimientoService;
    
    private String commandName;
    private Class commandClass;
    
    
    /** Logger for this class and subclasses */    
    protected final Log logger = LogFactory.getLog(getClass());
    
    public ComentarioController()
    {
        ParameterMethodNameResolver resolver = new ParameterMethodNameResolver();
        resolver.setParamName("method");
        resolver.setDefaultMethodName("paginacionPresOtrosBanc");
        setMethodNameResolver(resolver);
    }

    
    
    public ModelAndView cargaComentarioFrame(HttpServletRequest request, HttpServletResponse response)
    throws Exception
    {
    	
		ModelAndView mav = new ModelAndView("mantenimiento/comentarioframe");
		ComentarioForm form = new ComentarioForm();
		Object command = getCommandObject(request);
		form = (ComentarioForm)command;
		mav.addObject("form",form);
		
		return mav;
    }
    
    
    public ModelAndView cargaComentario(HttpServletRequest request, HttpServletResponse response)
    throws Exception
    {
    	
		ModelAndView mav = new ModelAndView("mantenimiento/comentario");
		
		ComentarioForm form = new ComentarioForm();
		Object command = getCommandObject(request);
		form = (ComentarioForm)command;

		
		
		
		mav.addObject("lstcomentario",mantenimientoService.listarComentario(form.getIdExpediente(),form.getIdUp()));
		
		return mav;
    }
    
    
     
   
    
    
    
    
    
    
   
    public Object getCommandObject(HttpServletRequest request)
    throws Exception
    {
    Object command = formBackingObject(request);
    bind(request, command);
    return command;
    }
    protected Object formBackingObject(HttpServletRequest request)
    throws Exception
    {
        return commandClass.newInstance();
    }

	
 

	public Class getCommandClass() {
		return commandClass;
	}


	public void setCommandClass(Class commandClass) {
		this.commandClass = commandClass;
	}


	public String getCommandName() {
		return commandName;
	}


	public void setCommandName(String commandName) {
		this.commandName = commandName;
	}


	
	
	public void setMantenimientoService(
			MantenimientoService mantenimientoService) {
		this.mantenimientoService = mantenimientoService;
	}
}
